﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Collections.Generic;
using Genetic;

namespace GeneticTest
{
    [TestClass]
    public class TestMastermind
    {
        [TestMethod]
        public void TestCrossover()
        {
            Char[] characterSet = {'a','b','c'};
            Mastermind mm = new Mastermind("abc", characterSet);
            String crossed = mm.crossover("abc", "bdd");
            List<String> expectedValues = new List<String>();
            for (int i = 0; i < 100; i++)
            {
                crossed = mm.crossover("abc", "bdd");
                Console.WriteLine(crossed);
                expectedValues.Add("bdd");
                expectedValues.Add("add");
                expectedValues.Add("abd");
                expectedValues.Add("abc");

                Assert.IsTrue(expectedValues.Contains(crossed));
            }            
        }
        [TestMethod]
        public void TestFitnessTest()
        {
            Char[] characterSet = { 'a', 'b', 'c', 'd' };
            Mastermind mm = new Mastermind("abc", characterSet);
            Assert.IsTrue(mm.fitnessTest("abc", "abd") == 4);
            Assert.IsTrue(mm.fitnessTest("abc", "ddd") == 0);
            Assert.IsTrue(mm.fitnessTest("abc", "acb") == 4);
            Assert.IsTrue(mm.fitnessTest("abc", "acd") == 3);
            Assert.IsTrue(mm.fitnessTest("abc", "cab") == 3);
            Assert.IsTrue(mm.fitnessTest("abc", "add") == 2);
            Assert.IsTrue(mm.fitnessTest("abc", "dda") == 1);
        }
    }
}
